package day_2022_9_to_12.Day;

/**
 * @author haomin
 * @date 2022/09/03 22:52
 **/
public class Day1_3_Num6172_IsStrictlyPalindromic {
    class Solution {
        public boolean isStrictlyPalindromic(int n) {
            int digit = 2;
            while(digit <= n-2){
                StringBuffer sb = new StringBuffer();
                int temp = n;
                while(temp != 0){
                    sb.append(temp % digit);
                    temp /= digit;
                }
                if(!judgeNum(sb.reverse().toString())) return false;
                digit++;
            }
            return true;
        }
        private boolean judgeNum(String s){
            int l = 0, r = s.length()-1;
            while(l <= r){
                if(s.charAt(l) == (s.charAt(r))){
                    l++;
                    r--;
                }else return false;
            }
            return true;
        }
    }
}